package com.yipinhouse.reception.app.apiImpl;

import cn.hutool.core.bean.BeanUtil;
import com.yipinhouse.common.result.Result;
import com.yipinhouse.loan.client.LoanCalQueryClient;
import com.yipinhouse.loan.client.param.AccumulationLoanParam;
import com.yipinhouse.loan.client.param.BusinessLoanParam;
import com.yipinhouse.loan.client.param.CombinedLoanParam;
import com.yipinhouse.loan.client.result.CalLoanResult;
import com.yipinhouse.reception.client.LoanCalWebQueryClient;
import com.yipinhouse.reception.client.param.AccumulationLoanWebParam;
import com.yipinhouse.reception.client.param.BusinessLoanWebParam;
import com.yipinhouse.reception.client.param.CombinedLoanWebParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
@Slf4j
@RestController
@RequestMapping("reception")
public class LoanCalWebApiImpl implements LoanCalWebQueryClient {

    @Resource
    private LoanCalQueryClient loanCalQueryClient;

    @Override
    public Result<CalLoanResult> calBusinessLoan(BusinessLoanWebParam param) {
        BusinessLoanParam businessLoanParam = BeanUtil.copyProperties(param, BusinessLoanParam.class);
        Result<CalLoanResult> calLoanResultResult = loanCalQueryClient.calBusinessLoan(businessLoanParam);
        return calLoanResultResult;
    }

    @Override
    public Result<CalLoanResult> calAccumulationLoan(AccumulationLoanWebParam param) {
        AccumulationLoanParam accumulationLoanParam = BeanUtil.copyProperties(param, AccumulationLoanParam.class);
        Result<CalLoanResult> calLoanResultResult = loanCalQueryClient.calAccumulationLoan(accumulationLoanParam);
        return calLoanResultResult;
    }

    @Override
    public Result<CalLoanResult> calCombinedLoan(CombinedLoanWebParam param) {
        CombinedLoanParam combinedLoanParam = BeanUtil.copyProperties(param, CombinedLoanParam.class);
        Result<CalLoanResult> calLoanResultResult = loanCalQueryClient.calCombinedLoan(combinedLoanParam);
        return calLoanResultResult;
    }
}
